﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Renren.Api;
using System.Collections.Specialized;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string xn_sig_added = Request.QueryString["xn_sig_added"];
            if (!string.IsNullOrEmpty(xn_sig_added))
            {
                if (xn_sig_added == "1")
                {
                    ApiSettings setting = new ApiSettings("0e91c1474004445a9f4a633706f19bf1", "e30ecf448e21410e85d9501bdeddf0da");
                    UserSession session = new UserSession();
                    IParser parser = new XmlParser();
                    Client client = new Client(setting, session, parser);
                    Session["xnClient"] = client;
                }
                else
                {
                    throw new Exception("Default.aspx出现错误，可能用户尚未授权导致");
                }
            }
            else
            {
                throw new Exception("Default.aspx出现错误，可能是未将对象设置到对象实力");
            }

        }
        catch
        {
            Response.Write("<script>top.location.href='http://app.renren.com/apps/tos.do?v=1.0&api_key=0e91c1474004445a9f4a633706f19bf1&next=http://apps.renren.com/renrencalendars/'</script>");
            Response.End();
        }
    }
}
